'\" te
.\" Copyright (c) 1992, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 1989 AT&T
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH PUT 9E "Mar 21, 2019"
.SH NAME
put \- receive messages from the preceding queue
.SH SYNOPSIS
.LP
.nf
#include <sys/types.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>



\fBint prefix\fR\fBrput\fR(\fBqueue_t *\fR\fIq\fR, \fBmblk_t\fR \fI*mp\fR);	/* read side */
.fi

.LP
.nf
\fBint prefix\fR\fBwput\fR(\fBqueue_t *\fR\fIq\fR, \fBmblk_t\fR \fI*mp\fR);	/* write side */
.fi

.SH INTERFACE LEVEL
.LP
Architecture independent level 1 (DDI/DKI). This entry point is required for
\fBSTREAMS. \fR
.SH ARGUMENTS
.ne 2
.na
\fB\fIq\fR \fR
.ad
.RS 7n
Pointer to the \fBqueue\fR(9S) structure.
.RE

.sp
.ne 2
.na
\fB\fImp\fR \fR
.ad
.RS 7n
Pointer to the message block.
.RE

.SH DESCRIPTION
.LP
The primary task of the \fBput()\fR routine is to coordinate the passing of
messages from one queue to the next in a stream. The \fBput()\fR routine is
called by the preceding stream component (stream module, driver, or stream
head). \fBput()\fR routines are designated ``write'' or ``read'' depending on
the direction of message flow.
.sp
.LP
With few exceptions, a streams module or driver must have a \fBput()\fR
routine. One exception is the read side of a driver, which does not need a
\fBput()\fR routine because there is no component downstream to call it. The
\fBput()\fR routine is always called before the component's corresponding
\fBsrv\fR(9E) (service) routine, and so \fBput()\fR should be used for the
immediate processing of messages.
.sp
.LP
A \fBput()\fR routine must do at least one of the following when it receives a
message:
.RS +4
.TP
.ie t \(bu
.el o
pass the message to the next component on the stream by calling the
\fBputnext\fR(9F) function;
.RE
.RS +4
.TP
.ie t \(bu
.el o
process the message, if immediate processing is required (for example, to
handle high priority messages); or
.RE
.RS +4
.TP
.ie t \(bu
.el o
enqueue the message (with the \fBputq\fR(9F) function) for deferred processing
by the service \fBsrv\fR(9E) routine.
.RE
.sp
.LP
Typically, a \fBput()\fR routine will switch on message type, which is
contained in the \fBdb_type\fR member of the \fBdatab\fR structure pointed to
by \fImp\fR. The action taken by the \fBput()\fR routine depends on the message
type. For example, a \fBput()\fR routine might process high priority messages,
enqueue normal messages, and handle an unrecognized \fBM_IOCTL\fR message by
changing its type to \fBM_IOCNAK\fR (negative acknowledgement) and sending it
back to the stream head using the \fBqreply\fR(9F) function.
.sp
.LP
The \fBputq\fR(9F) function can be used as a module's \fBput()\fR routine when
no special processing is required and all messages are to be enqueued for the
\fBsrv\fR(9E) routine.
.SH RETURN VALUES
.LP
Ignored.
.SH CONTEXT
.LP
\fBput()\fR routines do not have user context.
.SH SEE ALSO
.LP
.BR srv (9E),
.BR putctl (9F),
.BR putctl1 (9F),
.BR putnext (9F),
.BR putnextctl (9F),
.BR putnextctl1 (9F),
.BR putq (9F),
.BR qreply (9F),
.BR queue (9S),
.BR streamtab (9S)
.sp
.LP
\fIWriting Device Drivers\fR
.sp
.LP
\fISTREAMS Programming Guide\fR
